package chapter1.zyq1_str_obj;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class Student4List {
    static  List<Student4> stu_list=new ArrayList<>();


    static {
        Student4 ljw=new Student4(101, "李嘉威", 'M',
                LocalDate.of(2001, 4, 15), 2.89,
                Arrays.asList("平凡的世界","哈利波特与密室","从常青藤到华尔街") );

        Student4 sxq=new Student4(
                102, "孙小婧", 'F',
                LocalDate.of(2000, 5, 28), 3.76,
                Arrays.asList("叔本华思想随笔","哲学的殿堂","概率论与数理统计"));

        Student4 pk=new Student4(
                        103, "Peter Kevin", 'M',
                        LocalDate.of(2002, 12, 6), 3.28,
                        Arrays.asList("Java核心技术","雅舍小品"));

        Student4 lw=new Student4(
                        104, "陆伟", 'M',
                        LocalDate.of(2001, 7, 21), 3.35,
                        null);

        Student4 dly=new Student4(
                        105, "董丽仪", 'F',
                        LocalDate.of(2000, 8, 7), 2.95,
                        Arrays.asList("教育学原理（第2版）","茶花女")  );

        stu_list.add(ljw);
        stu_list.add(sxq);
        stu_list.add(pk);
        stu_list.add(lw);
        stu_list.add(dly);
    }

    public static Student4 getStudent(){
        Random rand = new Random();
        return stu_list.get(rand.nextInt(stu_list.size()));
    }

    public static List<Student4> getStudents(){
        return stu_list;
    }


}
